#include "equation.hpp"
#include "golden_ration.hpp"
#include "chords_method.hpp"
#include "halfdiv_method.hpp"
#include "newton_method.hpp"
#include <cmath>
#include <iostream>
#include <method.hpp>

static double f(double x) { return std::pow(x, 3) - 3 * std::sin(x); }
static double df(double x) { return 3 * std::pow(x, 2) - 3 * std::cos(x); }
static double d2f(double x) { return 6 * std::pow(x, 1) - 3 * std::cos(x); }

int main() {
  const double a = 0;
  const double b = 1;
  const double eps = 1e-3;

  Equation eq(f, df, d2f);

  std::cout << "Результаты: " << std::endl;

  auto halfdivm = HalfDivisionMethod();
  std::cout << halfdivm.getName() << ": " << halfdivm.solve(eq, a, b, eps)
            << std::endl;

  auto newton = NewtonMethod(0.5);
  std::cout << newton.getName() << ": " << newton.solve(eq, a, b, eps)
            << std::endl;

  auto chords = ChordsMethod();
  std::cout << chords.getName() << ": " << chords.solve(eq, a, b, eps)
            << std::endl;

  auto golden = GoldenRationMethod();
  std::cout << golden.getName() << ": " << golden.solve(eq, a, b, eps)
            << std::endl;
}